'usr strict';

var items = {};
exports.addItem = (key, item) => {
    items[key] = item;
    console.log(`add key: ${key}`);
};

exports.update = (key, item) => {
    if (!items[key]) throw new Exception("数据不存在不能修改");
    items[key] = item;
};

exports.remove = key => {
    delete items[key];
    console.log(`remove key: ${key}`);
};

exports.getItem = key => {
    if (items == null || items.length == 0)
        return null;
    console.log(`get key: ${key}`);
    return items[key];
};

exports.clear = () => {
    items = {};
    console.log('clear caches.');
};